﻿
namespace HSS.Interlink.Web
{
	#region TransmitFileCacheOptionalExtensions
	/// <summary>
	/// Extension methods for the <see cref="ITransmitFileCache"/> interface.
	/// </summary>
	public static class TransmitFileCacheOptionalExtensions
	{
		#region TryTransmitIfExists
		/// <summary>
		/// Attempt to transmit the cached file if it exists, specifing Attachment dispostion and auto content-type resolution.
		/// </summary>
		/// <param name="transmitFileCache">A concreate instance of <see cref="ITransmitFileCache"/></param>
		/// <param name="fileName">The name of the file to try and transmit.</param>
		/// <param name="handler">A <see cref="IDownloadHandler"/> instance responsible for delivering the file.</param>
		/// <returns>true if the file was found and transmitted; otherwise false.</returns>
		public static bool TryTransmitIfExists(this ITransmitFileCache transmitFileCache, string fileName, IDownloadHandler handler)
		{
			return transmitFileCache.TryTransmitIfExists(fileName, handler, true, "");
		}
		/// <summary>
		/// Attempt to transmit the cached file if it exists, specifing auto content-type resolution
		/// </summary>
		/// <param name="transmitFileCache">A concreate instance of <see cref="ITransmitFileCache"/></param>
		/// <param name="fileName">The name of the file to try and transmit.</param>
		/// <param name="handler">A <see cref="IDownloadHandler"/> instance responsible for delivering the file.</param>
		/// <param name="attachment">true to send with Attachment Disposition; otherwise false for Inline Disposition.</param>
		/// <returns>true if the file was found and transmitted; otherwise false.</returns>
		public static bool TryTransmitIfExists(this ITransmitFileCache transmitFileCache, string fileName, IDownloadHandler handler, bool attachment)
		{
			return transmitFileCache.TryTransmitIfExists(fileName, handler, attachment, "");
		}
		#endregion
	}
	#endregion
}